#include <stdio.h>
#include "ofc/DData.h"

int main(int argc, char *argv[])
{
  DData *dat1 = [DData alloc];
  DData *dat2 = [DData new  ];
  DText *str;

  [dat1 init :"DData stores data strings" :25]; // Init with a data string

  printf("Length of data string1:%ld\n", [dat1 length]);

  str = [dat1 tohexString];
  printf("Hex string of data string:%s.\n", [str cstring]);
  [str free];

  str = [dat1 toBase64];
  printf("Base64 string of data string:%s.\n", [str cstring]);
  [str free];

  printf("Hash value of data string:%ld.\n", [dat1 hash]);

  printf("Index of \"data\" in data string is:%ld.\n", [dat1 index :"data" :4 :0 :-1]);

  [dat2 set :"DData stores data strings" :1 :17]; // Set with substring

  [dat2 put :16 :'!'];                 // Put a character in the string

  [dat2 insert :16 :16 :" strings" :9]; // Insert a data string

  [dat2 delete :11 :15];               // Delete a substring

  str = [dat2 toText];
  printf("Data string2:%s.\n", [str cstring]);
  [str free];

  printf("Data string1 is ");          // Compare strings
  if ([dat1 compare :dat2] > 0)
    printf("greater");
  else if ([dat1 compare :dat2] < 0)
    printf("smaller");
  else
    printf("equal");
  printf(" than data string2.\n");

  [dat1 free];                         // Cleanup
  [dat2 free];

  return 0;
}
